#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_exam1.py
# author:王雯雯
# datetime:2024-11-12 
# software: PyCharm


class Dog:
    def __init__(self):
        self.dogs_info = [
            {"color": "黑色", "quantity": 5, "price": 500},
            {"color": "白色", "quantity": 3, "price": 600},
            {"color": "棕色", "quantity": 4, "price": 550}
        ]

    def buy_dog(self, color, quantity):
        for dog in self.dogs_info:
            if dog["color"] == color:
                if dog["quantity"] >= quantity:
                    dog["quantity"] -= quantity
                    return f"成功购买{quantity}只{color}的狗。"
                else:
                    return f"没有足够数量的{color}狗可供购买。"
        return f"没有找到{color}的狗。"

    def sell_dog(self, color, quantity):
        for dog in self.dogs_info:
            if dog["color"] == color:
                dog["quantity"] += quantity
                return f"成功出售{quantity}只{color}的狗。"
        return f"没有找到{color}的狗。"

    def print_dog_quantity(self):
        print("剩余狗的数量:")
        for dog in self.dogs_info:
            print(f"{dog['color']}: {dog['quantity']}只")